package com.ycgwl.web.controller;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ycgwl.web.bean.TestCat;

@Controller
@RequestMapping("/test")
public class testController {
	private static Logger logger = Logger.getLogger(testController.class);

	@RequestMapping(value = "/search.do", method = RequestMethod.GET)
	public @ResponseBody String search(HttpServletRequest request) {

		return "hah";
	}

	@RequestMapping(value = "/search1", method = RequestMethod.GET)
	public @ResponseBody String search1() {

		return "xixi";
	}

	@RequestMapping(value = "/test3.do", method = RequestMethod.GET)
	public Map test3() {
		System.out.println("进入test3");
		Map map = new HashMap<>();
		map.put("hh", "heiya");
		return map;
	}

	@RequestMapping(value = "/test1.do", method = RequestMethod.GET)
	public @ResponseBody Map test1(TestCat cat) {
		try {
			cat.setName(URLDecoder.decode(cat.getName(), "UTF-8"));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("姓名：" + cat.getName() + "身高：" + cat.getHeight() + "年龄" + cat.getAge());
		Map<String, String> map = new HashMap<>();
		return map;
	}
}
